package com.framework.plm.sch.job;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.framework.plm.bas.exception.PlmBasException;
import com.framework.plm.bas.param.GeneralParam;
import com.framework.plm.sch.util.PlmSchConstant;
import com.framework.plm.sch.vo.HpSchTaskVO;

public abstract class AbsBatchJob extends AbsPlmSchJob {
	private static final Log log = LogFactory.getLog(AbsBatchJob.class);

	public boolean checkJobPrev(GeneralParam param) {
		return true;
	}

	public void doJob(GeneralParam param) {
		try{
			if(checkJobPrev(param)){
				taskBeforeLog(param);
				HpSchTaskVO schTaskVO = (HpSchTaskVO)param.getValueObject(PlmSchConstant.TASK_OBJECT);
				doPlanWork(schTaskVO, param);
				taskAfterLog(param);
			}
		}catch(Exception e){
			taskThrowLog(param, e);
			log.error(e);
			HpSchTaskVO schTaskVO = (HpSchTaskVO)param.getValueObject(PlmSchConstant.TASK_OBJECT);
			throw new PlmBasException(PlmSchConstant.MSG_0000, new Object[]{schTaskVO.getTaskName(), e.getMessage()});
		}
	}
	
	public abstract void doPlanWork(HpSchTaskVO schTaskVO, GeneralParam param);


}
